package com.jhte.scheduleJob.service;

import com.jhte.scheduleJob.base.util.BaseResponse;
import com.jhte.scheduleJob.entity.ScheduleJob;
import com.jhte.scheduleJob.vo.JobKeyRequest;
import org.quartz.SchedulerException;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.List;

/**
 * @author wuchun
 * @description
 * @create 2018-01-31 11:42
 */
@Service
public interface ScheduleJobService {

    /**
     * 添加任务
     *
     * @param job
     * @throws SchedulerException
     */
    void addScheduleJob(ScheduleJob job) throws SchedulerException, ParseException;

    /**
     * 修改任务
     *
     * @param job
     * @throws SchedulerException
     */
    void updateScheduleJob(ScheduleJob job) throws SchedulerException, ParseException;

    /**
     * 暂停任务
     *
     * @param jobKeyRequest
     * @throws Exception
     */
    void pauseScheduleJob(JobKeyRequest jobKeyRequest) throws Exception;

    /**
     * 恢复任务
     *
     * @param jobKeyRequest
     * @throws Exception
     */
    void resumeScheduleJob(JobKeyRequest jobKeyRequest) throws Exception;

    /**
     * 删除任务
     *
     * @param jobKeyRequest
     * @throws Exception
     */
    void deleteScheduleJob(JobKeyRequest jobKeyRequest) throws Exception;

    /**
     * 立即执行job
     *
     * @param jobKeyRequest
     * @throws SchedulerException
     */
    void executeJobNow(JobKeyRequest jobKeyRequest) throws SchedulerException;

    /**
     * 获取所有计划中的任务列表
     *
     * @return
     * @throws SchedulerException
     */
    List<ScheduleJob> getAllJobs() throws Exception;

    /**
     * 所有正在运行的job
     *
     * @return
     * @throws SchedulerException
     */
    List<ScheduleJob> getRunningJobs() throws Exception;

    /**
     * 检查执行任务的类和方法是否存在
     *
     * @param scheduleJob
     * @return
     * @throws Exception
     */
    BaseResponse checkClassAndMethod(ScheduleJob scheduleJob) throws Exception;

}
